<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="domain.Worker"%>
<%
request.setCharacterEncoding("UTF-8");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>员工登录</title>
<meta name="author" content="DeathGhost" />
<link rel="stylesheet" type="text/css" href="css/style.css" tppabs="css/style.css" />
<style>
body{height:100%;background:#16a085;overflow:hidden;}
canvas{z-index:-1;position:absolute;}
</style>
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/verificationNumbers.js" tppabs="js/verificationNumbers.js"></script>
<script type="text/javascript" src="js/Particleground.js" tppabs="js/Particleground.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  //粒子背景特效
  $('body').particleground({
    dotColor: '#5cbdaa',
    lineColor: '#5cbdaa'
  });
  //验证码
  createCode();
  //测试提交，对接程序删除即可
  $(".submit_btn").click(function(){
	  location.href="javascrpt:;"/*tpa=http://***index.html*/;
	  });
});
function login(){
	if(validate()==true){
		var workerAccount = document.getElementById("workerAccount").value;
		var workerPassword = document.getElementById("workerPassword").value;
		if(workerAccount==""){
			document.getElementById("workerAccount").value="用户名不能为空";
		}else if(workerPassword==""){
			document.getElementById("workerPassword").value="密码不能为空";
		}else{
			window.location.href = window.location.protocol+"//"+window.location.host+"/PetsManagement/worker/workerLoginServlet?workerAccount="+workerAccount+"&workerPassword="+workerPassword;
		}
	}
}
function goToRegist(){
	window.location.href = window.location.protocol+"//"+window.location.host+"/PetsManagement/register.jsp";
}
</script>
</head>
<%
	
	String massage = "";
	massage = (String)session.getAttribute("massage");
	session.setAttribute("massage", "");
	String workerName="";
	Worker worker = (Worker)session.getAttribute("worker");
	
	try{
		if(massage==null){
			massage="";
		}
		if(worker!=null){
			workerName = worker.getWorkerName();
			massage = "";
		}
	}catch(Exception e){
		//request.getRequestDispatcher("/login.jsp").forward(request, response);
		session.setAttribute("massage", "登陆失败，用户名或密码错误！请重新登录！");
		response.sendRedirect("/PetsManagement/login.jsp");
	} 
 %>
<body onload="createCode()" id="loginPage">
<dl class="admin_login">
 <dt>
  <strong>宠物管理系统后台</strong>
  <em>PetsManager System</em>
 </dt>
 <dt>
  <strong ><font color="#B32048"><%=massage %></font></strong>
 </dt>
 <dd class="cou_icon">
  <input type="text" placeholder="账号" class="login_txtbx" name="workerAccount" id="workerAccount"/>
 </dd>
 <dd class="pwd_icon">
  <input type="password" placeholder="密码" class="login_txtbx" name="workerPassword" id="workerPassword"/>
 </dd>
 <dd class="val_icon">
  <div class="checkcode">
    <input type="text" id="J_codetext" placeholder="输入验证码" maxlength="4" class="login_txtbx" name="validateCodes">
    <canvas class="J_codeimg" id="myCanvas" onclick="createCode()">对不起，您的浏览器不支持canvas，请下载最新版浏览器!</canvas>
  </div>
  <input type="button" value="刷新验证码" class="ver_btn" onClick="createCode();">
 </dd>
 <dd>
  <input id="login" type="button" value="立即登陆" class="submit_btn" onClick="login();">
 </dd>
 <dd>
  <input id="goToRegist" type="button" value="游客注册" class="submit_btn" onClick="goToRegist();">
 </dd>
 <dd>
  <p>© 2020-2020 宠物管理系统 版权所有</p>
  <p>豫 475500</p>
 </dd>
</dl>
</body>
<!-- </form> -->
</html>
